classdef Temperature < Processor
  % Class for calculating temperature ala SBE Data Procesing
  % Derived from Processor
  % Constructor signature: T = Temperature(data, conn), args. optional
  %
  % Author: David Goldsmith, Wash. State Dept. of Ecology, dgol461@ecy.wa.gov
  % Release date: N/A
  
    properties
      % inherited from Processor
%         inData;
%         castDT;
%         scanRate;
%         ParamID;
%         ParamDesc;
%         SBEprec;
%         EquipID;
        DBdata;
        outData;
    end
    
    methods
        function T = Temperature(data, conn) % Constructor
            if nargin < 1, data = []; end
            if nargin < 2, conn = []; end
            T = T@Processor(data);
            if ~isempty(conn), T.getDBdata(conn, 'T'); end
            if ~isempty(conn) && ~isempty(data), T.mainFormula; end
%            if ~isempty(T.outData), T.outData = round2(T.outData, 1e-4); end
        end
        
        function delete(obj) % Destructor
            % Here in case I need it
        end
        
        function mainFormula(obj)
            tmp = obj.inData.Sensors.TemperatureSensor;
            f0 = tmp.F0;
            g  = tmp.G; 
            h  = tmp.H;  
            i  = tmp.I;  
            j  = tmp.J;
            f = obj.inData.Tf;
            x = log(f0./f);
            obj.outData = 1 ./ (g + h*x + i*x.^2 + j*x.^3) - 273.15;
        end
        
    end
    
end